home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
cool
/
ge_cool.lha
/
GE_COOL2.1
/
src
/
Range
/
Range.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-15
|
3KB
|
83 lines
//
// Copyright (C) 1991 Texas Instruments Incorporated.
//
// Permission is granted to any individual or institution to use, copy, modify,
// and distribute this software, provided that this complete copyright and
// permission notice is maintained, intact, in all copies and supporting
// documentation.
//
// Texas Instruments Incorporated provides this software "as is" without
// express or implied warranty.
//
//
#include <cool/Range.h>
// CoolRange<Type,lbound,hbound> -- Constructor with initial value
// Input: Reference to value
// Output: None
template <class Type, Type lbound, Type hbound>
CoolRange<Type,lbound,hbound>::CoolRange<Type,lbound,hbound> (const Type& value) {
this->set(value);
}
// CoolRange<Type,lbound,hbound> -- Constructor with reference to another range
// object
// Input: Reference to CoolRange<Type,lbound,hbound> object
// Output: None
template <class Type, Type lbound, Type hbound>
CoolRange<Type,lbound,hbound>::CoolRange<Type,lbound,hbound>
(const CoolRange<Type,lbound,hbound>& r) {
this->data = r.data; // Copy data value
}
// operator= -- Overload the assignment operator to copy the value of one
// CoolRange<Type,lbound,hbound> object to another
// Input: Reference to object
// Output: Reference to updated object
template <class Type, Type lbound, Type hbound>
CoolRange<Type,lbound,hbound>& CoolRange<Type,lbound,hbound>::operator= (const CoolRange<Type,lbound,hbound>& r) {
this->data = r.data; // Copy data value
return *this; // Return reference to object
}
// value_string -- method to convert value to string
// Input: None
// Output: string for value
template <class Type, Type lbound, Type hbound>
char* CoolRange<Type,lbound,hbound>::value_string() const {
ostream str_stream(MSG_MAX, msg_buffer);
str_stream << data; // "print" value into buffer
return strdup(msg_buffer);
}
template <class Type, Type lbound, Type hbound>
void CoolRange<Type,lbound,hbound>::report_set_error () const {
if (this->data < this->low_bound)
this->set_low_error (#Type, #lbound, #hbound,
this->value_string());
else if (this->data > this->high_bound)
this->set_upper_error (#Type, #lbound, #hbound,
this->value_string());
}
template <class Type, Type lbound, Type hbound>
void CoolRange<Type,lbound,hbound>::do_compare () const {
if ((*this->compare_s)(this->data, this->low_bound) < 0) // Lower bounds
this->set_low_error (#Type, #lbound, #hbound,
this->value_string());
else if ((*this->compare_s)(this->data, this->high_bound) > 0)// Upper bounds
this->set_upper_error (#Type, #lbound, #hbound,
this->value_string());
}